package model;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import utils.SetUtils;

public class Comment {

    @SerializedName("id")
    @Expose
    private Integer id;
    @SerializedName("article_id")
    @Expose
    private Integer articleId;
    @SerializedName("user_id")
    @Expose
    private Integer userId;
    @SerializedName("parent_comment_id")
    @Expose
    private Integer parentCommentId;
    @SerializedName("content")
    @Expose
    private String content;
    @SerializedName("created_at")
    @Expose
    private String createdAt;
    @SerializedName("updated_at")
    @Expose
    private String updatedAt;
    @SerializedName("child_comment")
    @Expose
    private List<ChildComment> childComment = new ArrayList<ChildComment>();
    @SerializedName("user")
    @Expose
    private Article_User user;

    /**
     * 
     * @return
     *     The id
     */
    public Integer getId() {
        return id;
    }
    
    public Comment(String createdAt){
    	this.createdAt=createdAt;
    }

    /**
     * 
     * @param id
     *     The id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * 
     * @return
     *     The articleId
     */
    public Integer getArticleId() {
        return articleId;
    }

    /**
     * 
     * @param articleId
     *     The article_id
     */
    public void setArticleId(Integer articleId) {
        this.articleId = articleId;
    }

    /**
     * 
     * @return
     *     The userId
     */
    public Integer getUserId() {
        return userId;
    }

    /**
     * 
     * @param userId
     *     The user_id
     */
    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    /**
     * 
     * @return
     *     The parentCommentId
     */
    public Integer getParentCommentId() {
        return parentCommentId;
    }

    /**
     * 
     * @param parentCommentId
     *     The parent_comment_id
     */
    public void setParentCommentId(Integer parentCommentId) {
        this.parentCommentId = parentCommentId;
    }

    /**
     * 
     * @return
     *     The content
     */
    public String getContent() {
        return content;
    }

    /**
     * 
     * @param content
     *     The content
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * 
     * @return
     *     The createdAt
     */
    public String getCreatedAt() {
        return createdAt;
    }

    /**
     * 
     * @param createdAt
     *     The created_at
     */
    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    /**
     * 
     * @return
     *     The updatedAt
     */
    public String getUpdatedAt() {
        return updatedAt;
    }

    /**
     * 
     * @param updatedAt
     *     The updated_at
     */
    public void setUpdatedAt(String updatedAt) {
        this.updatedAt = updatedAt;
    }

    /**
     * 
     * @return
     *     The childComment
     */
    public List<ChildComment> getChildComment() {
        return childComment;
    }

    /**
     * 
     * @param childComment
     *     The child_comment
     */
    public void setChildComment(List<ChildComment> childComment) {
        this.childComment = childComment;
    }
    /**
     * 
     * @return
     *     The user
     */
    public Article_User getUser() {
        return user;
    }

    /**
     * 
     * @param user
     *     The user
     */
    public void setUser(Article_User user) {
        this.user = user;
    }

	@Override
	public String toString() {
		return "Comment [id=" + id + ", articleId=" + articleId + ", userId=" + userId + ", parentCommentId="
				+ parentCommentId + ", content=" + content + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt
				+ ", childComment=" + childComment + ", user=" + user + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((articleId == null) ? 0 : articleId.hashCode());
		result = prime * result + ((childComment == null) ? 0 : childComment.hashCode());
		result = prime * result + ((content == null) ? 0 : content.hashCode());
		result = prime * result + ((createdAt == null) ? 0 : createdAt.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((parentCommentId == null) ? 0 : parentCommentId.hashCode());
		result = prime * result + ((updatedAt == null) ? 0 : updatedAt.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Comment other = (Comment) obj;
		if (articleId == null) {
			if (other.articleId != null)
				return false;
		} else if (!articleId.equals(other.articleId))
			return false;
		if (childComment == null) {
			if (other.childComment != null)
				return false;
		} else if (!childComment.equals(other.childComment))
			return false;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (createdAt == null) {
			if (other.createdAt != null)
				return false;
		} else if (!createdAt.equals(other.createdAt))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (parentCommentId == null) {
			if (other.parentCommentId != null)
				return false;
		} else if (!parentCommentId.equals(other.parentCommentId))
			return false;
		if (updatedAt == null) {
			if (other.updatedAt != null)
				return false;
		} else if (!updatedAt.equals(other.updatedAt))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}

//	@Override
//	public int compareTo(Comment comment) {
//		long changDate1 = SetUtils.ChangDate(this.createdAt);
//		long changDate2 = SetUtils.ChangDate(comment.createdAt);
//		int time1=(int) changDate1;
//		int time2=(int) changDate2;
////		
//		if(time1<time2)return 1;
//		  else if(time1==time2)
//			  return 0;
//		  else return -1;
//	}
	
	
}
